package net.exoweb.animate.graphics
{
    import net.exoweb.animate.common.*;
    import net.exoweb.animate.graphics.*;

    public class GFan extends GShape
    {
        protected var _radius:Number;
        protected var _count:Number;

        public function GFan(radius:Number=10, count:Number=12, color:uint=0xFFFFFF, bm:String="normal")
        {
            super(color, bm);
            _radius = radius;
            _count = count;
        }

        public function set radius(v:Number):void
        {
            _radius = v;
            display();
        }

        public function get radius():Number
        {
            return _radius;
        }

        public function set count(v:Number):void
        {
            _count = v;
            display();
        }

        public function get count():Number
        {
            return _count;
        }

        override public function display():void
        {
            graphics.clear();
            graphics.beginFill(color);
            for(var i:int=0; i<360; i+=(360/_count))
            {
                var radian:Number = Maths.getRadian(i);
                var x:Number = _radius * Math.cos(radian);
                var y:Number = _radius * Math.sin(radian);
                graphics.drawCircle(x, y, _radius);
            }
            graphics.endFill();
            graphics.beginFill(color);
            graphics.drawCircle(0, 0, _radius/2);
            graphics.endFill();
        }
    }
}
